package leetcode;

/**
 * Created with IntelliJ IDEA.
 * User: Ghost
 * Date: 14-6-18
 * Time: 下午4:48
 * To change this template use File | Settings | File Templates.
 */
public class Remove_Duplicates_from_Sorted_Array {
    public int removeDuplicates(int[] A) {
        int size = A.length;
        if (size==0)
            return size;
        int flagIndex = 0;
        int i=1;
        while(i<A.length){
            while (i<A.length && A[i]==A[flagIndex]) {
                i++;
            }
            if(i==A.length){
                return flagIndex+1;
            }
            else{
                flagIndex++;
                A[flagIndex] = A[i];
                i++;
            }
        }
        return flagIndex+1;
    }
    public static void main(String[] args){
        Remove_Duplicates_from_Sorted_Array remove_duplicates_from_sorted_array = new Remove_Duplicates_from_Sorted_Array();
        int[] A = {1};
        System.out.println(remove_duplicates_from_sorted_array.removeDuplicates(A));

    }
}
